package com.lagou.bean;

import com.lagou.service.HelloService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Component;

import java.util.Random;

@Component
public class ConsumerComponent {

    @Reference
    private HelloService helloService;

    public void methodA() {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    Random random = new Random();
                    long timeToWait = random.nextInt(100);
                    String result = helloService.methodA(timeToWait);
                    System.out.println("==result: " + result);

                }
            }
        };
        Thread thread = new Thread(runnable);
        thread.start();
    }

    public void methodB() {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    Random random = new Random();
                    long timeToWait = random.nextInt(100);
                    String result = helloService.methodB(timeToWait);
                    System.out.println("==result: " + result);
                }
            }
        };
        Thread thread = new Thread(runnable);
        thread.start();
    }

    public void methodC() {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    Random random = new Random();
                    long timeToWait = random.nextInt(100);
                    String result = helloService.methodC(timeToWait);
                    System.out.println("==result: " + result);
                }
            }
        };
        Thread thread = new Thread(runnable);
        thread.start();
    }

}
